package com.bw.coll;

import com.bw.bean.Emp;
import com.bw.bean.Emp1;
import com.bw.bean.Emp2;
import com.bw.service.EmpService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class EmpColl {

    @Autowired
    EmpService emp;

    @RequestMapping("/list1")
    public String getList1(){
        List<Emp1> list1 = emp.getList1();
        ArrayList<String> list = new ArrayList<>();
        list.add("章节名称");
        list.add("播放次数");
        list.add("播放时长");
        list.add("观看人数");
        list.add("人均观看时长");
        return SugarUtil.getTablePlayData(list,list1);
    }

    @RequestMapping("/list2")
    public Map getList2(){
        List<Emp> list2 = emp.getList2();
        return SugarUtil.getPieData(list2);
    }

    @RequestMapping("/list3")
    public Map getList3(){
        List<Emp> list3 = emp.getList3();
        return SugarUtil.getMapData(list3);
    }

    @RequestMapping("/list4")
    public Map getList4(){
        Double list4 = emp.getList4();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("status",0);
        map.put("data",list4);
        return map;
    }

    @RequestMapping("/list5")
    public Map getList5(){
        List<Emp> list5 = emp.getList5();
        return SugarUtil.getBarData(list5);
    }

    @RequestMapping("/list6")
    public String getList6(){
        List<Emp2> list6 = emp.getList6();
        ArrayList<String> list = new ArrayList<>();
        list.add("来源名称");
        list.add("订单金额");
        list.add("下单用户总数");
        list.add("订单总数");
        return SugarUtil.getTablePlayData(list,list6);
    }

    @RequestMapping("/list7")
    public Map getList7(){
        Double list7 = emp.getList7();
        HashMap<Object, Object> map = new HashMap<>();
        map.put("status",0);
        map.put("data",list7);
        return map;
    }

    @RequestMapping("/list8")
    public String getList8(){
        List<Emp> list8 = emp.getList8();
        ArrayList<String> list = new ArrayList<>();
        list.add("名称");
        list.add("订单金额");
        return SugarUtil.getTablePlayData(list,list8);
    }

}
